package cn.sciento.farm.devicemanager.fjhsxq.model.common;

public enum ResultConstant {
    FAILED(0, "操作失败"),

    SUCCESS(1, "操作成功"),

    ROLLBACK_EXCEPTION(10211,"操作失败"),

    // 错误
    INTERNAL_ERROR(12150,"内部错误");

    public int code;

    public String message;

    ResultConstant(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public static ResultConstant match(int code) {
        for (ResultConstant resultConstant : ResultConstant.values()) {
            if (resultConstant.getCode() == code) {
                return resultConstant;
            }
        }
        return SUCCESS;
    }
}